package com.example.lxc415billiards.service.Impl;

import com.example.lxc415billiards.domain.User;
import com.example.lxc415billiards.mapper.UserMapper;
import com.example.lxc415billiards.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getAllUsers() {
        return userMapper.selectAllUsers();
    }

    @Override
    public User getUserById(Long id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public User getUserByUserName(String userName) {
        return userMapper.selectUserByUserName(userName);
    }

    @Override
    public User addUser(User user) {
        userMapper.insertUser(user);
        return user;
    }

    @Override
    public void deleteUserById(Long id) {
        userMapper.deleteUserById(id);
    }

    @Override
    public User updateUser(User user) {
        userMapper.updateUser(user);
        return user;
    }
}
